package com.example.demo_one.kotlin

fun main() {
    val person = Person2("张三")
    person.show()
    val person2 = Person2("张三", 18)
    person2.show2()
    val person3 = Person2("张三", 18, "男")
    person3.show3()
}
class Person2(var name:String){
    var age:Int = 0
    var sex:String = ""
    constructor(name:String, age:Int): this(name){
        this.age = age
    }
    constructor(name:String, age:Int, sex:String): this(name){
        this.age = age
        this.sex = sex
    }
    fun show(){
        println("姓名: $name")
    }
    fun show2(){
        println("姓名: $name, 年龄: $age")
    }
    fun show3(){
        println("姓名: $name, 年龄: $age, 性别: $sex")
    }
}